/*
 *  trace.hpp - debug tracing
 *
 *    Copyright (c) 2001-2006, Luxena Company. All rights reserved.
 *
 *  Purpose:
 *
 */

#ifndef _TRACE_HPP
#define _TRACE_HPP

#ifndef __cplusplus
#error This header requires a C++ compiler ...
#endif

#ifdef __TRACE__

#include <stdarg.h>

class log_file
{
private:
	FILE *m_f;

public:
	log_file (char *pszFileName)
	{
		m_f = fopen(pszFileName, "a");
	}
	~log_file ()
	{
		fclose(m_f);
	}
	void write (char *fmt, ...)
	{
		va_list ap;
		va_start(ap, fmt);
		vfprintf(m_f, fmt, ap);
		fflush(m_f);
		va_end(ap);
	}
};

log_file _log("dbexp.log");

#ifdef __GNUC__
#define TRACE(...) _log.write(__VA_ARGS__)
#endif

#ifdef _MSC_VER
#define TRACE _log.write
#endif

#else // __TRACE__

#ifdef __GNUC__
#define TRACE(...)
#endif

#ifdef _MSC_VER
#define SLASH /
#define TRACE SLASH/
#endif

#endif // __TRACE__

#endif // _TRACE_HPP
